/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package lego.impl;

import lego.ActionerPort;
import lego.LegoPackage;
import lego.Robot;
import lego.SensorPort;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Robot</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link lego.impl.RobotImpl#getActionerPorts <em>Actioner Ports</em>}</li>
 *   <li>{@link lego.impl.RobotImpl#getSensorPorts <em>Sensor Ports</em>}</li>
 *   <li>{@link lego.impl.RobotImpl#getName <em>Name</em>}</li>
 *   <li>{@link lego.impl.RobotImpl#isBluetoothVisible <em>Bluetooth Visible</em>}</li>
 *   <li>{@link lego.impl.RobotImpl#isBluetoothOn <em>Bluetooth On</em>}</li>
 *   <li>{@link lego.impl.RobotImpl#getConnectionStatus <em>Connection Status</em>}</li>
 *   <li>{@link lego.impl.RobotImpl#getID <em>ID</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class RobotImpl extends EObjectImpl implements Robot {
	/**
	 * The cached value of the '{@link #getActionerPorts() <em>Actioner Ports</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getActionerPorts()
	 * @generated
	 * @ordered
	 */
	protected EList<ActionerPort> actionerPorts;

	/**
	 * The cached value of the '{@link #getSensorPorts() <em>Sensor Ports</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSensorPorts()
	 * @generated
	 * @ordered
	 */
	protected EList<SensorPort> sensorPorts;

	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = "robotName";

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The default value of the '{@link #isBluetoothVisible() <em>Bluetooth Visible</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isBluetoothVisible()
	 * @generated
	 * @ordered
	 */
	protected static final boolean BLUETOOTH_VISIBLE_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isBluetoothVisible() <em>Bluetooth Visible</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isBluetoothVisible()
	 * @generated
	 * @ordered
	 */
	protected boolean bluetoothVisible = BLUETOOTH_VISIBLE_EDEFAULT;

	/**
	 * The default value of the '{@link #isBluetoothOn() <em>Bluetooth On</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isBluetoothOn()
	 * @generated
	 * @ordered
	 */
	protected static final boolean BLUETOOTH_ON_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isBluetoothOn() <em>Bluetooth On</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isBluetoothOn()
	 * @generated
	 * @ordered
	 */
	protected boolean bluetoothOn = BLUETOOTH_ON_EDEFAULT;

	/**
	 * The default value of the '{@link #getConnectionStatus() <em>Connection Status</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConnectionStatus()
	 * @generated
	 * @ordered
	 */
	protected static final int CONNECTION_STATUS_EDEFAULT = -1;

	/**
	 * The cached value of the '{@link #getConnectionStatus() <em>Connection Status</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConnectionStatus()
	 * @generated
	 * @ordered
	 */
	protected int connectionStatus = CONNECTION_STATUS_EDEFAULT;

	/**
	 * The default value of the '{@link #getID() <em>ID</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getID()
	 * @generated
	 * @ordered
	 */
	protected static final int ID_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getID() <em>ID</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getID()
	 * @generated
	 * @ordered
	 */
	protected int iD = ID_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RobotImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return LegoPackage.Literals.ROBOT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ActionerPort> getActionerPorts() {
		if (actionerPorts == null) {
			actionerPorts = new EObjectContainmentEList<ActionerPort>(ActionerPort.class, this, LegoPackage.ROBOT__ACTIONER_PORTS);
		}
		return actionerPorts;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<SensorPort> getSensorPorts() {
		if (sensorPorts == null) {
			sensorPorts = new EObjectContainmentEList<SensorPort>(SensorPort.class, this, LegoPackage.ROBOT__SENSOR_PORTS);
		}
		return sensorPorts;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, LegoPackage.ROBOT__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isBluetoothVisible() {
		return bluetoothVisible;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBluetoothVisible(boolean newBluetoothVisible) {
		boolean oldBluetoothVisible = bluetoothVisible;
		bluetoothVisible = newBluetoothVisible;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, LegoPackage.ROBOT__BLUETOOTH_VISIBLE, oldBluetoothVisible, bluetoothVisible));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isBluetoothOn() {
		return bluetoothOn;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBluetoothOn(boolean newBluetoothOn) {
		boolean oldBluetoothOn = bluetoothOn;
		bluetoothOn = newBluetoothOn;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, LegoPackage.ROBOT__BLUETOOTH_ON, oldBluetoothOn, bluetoothOn));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getConnectionStatus() {
		return connectionStatus;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setConnectionStatus(int newConnectionStatus) {
		int oldConnectionStatus = connectionStatus;
		connectionStatus = newConnectionStatus;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, LegoPackage.ROBOT__CONNECTION_STATUS, oldConnectionStatus, connectionStatus));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getID() {
		return iD;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setID(int newID) {
		int oldID = iD;
		iD = newID;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, LegoPackage.ROBOT__ID, oldID, iD));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case LegoPackage.ROBOT__ACTIONER_PORTS:
				return ((InternalEList<?>)getActionerPorts()).basicRemove(otherEnd, msgs);
			case LegoPackage.ROBOT__SENSOR_PORTS:
				return ((InternalEList<?>)getSensorPorts()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case LegoPackage.ROBOT__ACTIONER_PORTS:
				return getActionerPorts();
			case LegoPackage.ROBOT__SENSOR_PORTS:
				return getSensorPorts();
			case LegoPackage.ROBOT__NAME:
				return getName();
			case LegoPackage.ROBOT__BLUETOOTH_VISIBLE:
				return isBluetoothVisible();
			case LegoPackage.ROBOT__BLUETOOTH_ON:
				return isBluetoothOn();
			case LegoPackage.ROBOT__CONNECTION_STATUS:
				return getConnectionStatus();
			case LegoPackage.ROBOT__ID:
				return getID();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case LegoPackage.ROBOT__NAME:
				setName((String)newValue);
				return;
			case LegoPackage.ROBOT__BLUETOOTH_VISIBLE:
				setBluetoothVisible((Boolean)newValue);
				return;
			case LegoPackage.ROBOT__BLUETOOTH_ON:
				setBluetoothOn((Boolean)newValue);
				return;
			case LegoPackage.ROBOT__CONNECTION_STATUS:
				setConnectionStatus((Integer)newValue);
				return;
			case LegoPackage.ROBOT__ID:
				setID((Integer)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case LegoPackage.ROBOT__NAME:
				setName(NAME_EDEFAULT);
				return;
			case LegoPackage.ROBOT__BLUETOOTH_VISIBLE:
				setBluetoothVisible(BLUETOOTH_VISIBLE_EDEFAULT);
				return;
			case LegoPackage.ROBOT__BLUETOOTH_ON:
				setBluetoothOn(BLUETOOTH_ON_EDEFAULT);
				return;
			case LegoPackage.ROBOT__CONNECTION_STATUS:
				setConnectionStatus(CONNECTION_STATUS_EDEFAULT);
				return;
			case LegoPackage.ROBOT__ID:
				setID(ID_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case LegoPackage.ROBOT__ACTIONER_PORTS:
				return actionerPorts != null && !actionerPorts.isEmpty();
			case LegoPackage.ROBOT__SENSOR_PORTS:
				return sensorPorts != null && !sensorPorts.isEmpty();
			case LegoPackage.ROBOT__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case LegoPackage.ROBOT__BLUETOOTH_VISIBLE:
				return bluetoothVisible != BLUETOOTH_VISIBLE_EDEFAULT;
			case LegoPackage.ROBOT__BLUETOOTH_ON:
				return bluetoothOn != BLUETOOTH_ON_EDEFAULT;
			case LegoPackage.ROBOT__CONNECTION_STATUS:
				return connectionStatus != CONNECTION_STATUS_EDEFAULT;
			case LegoPackage.ROBOT__ID:
				return iD != ID_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(", bluetoothVisible: ");
		result.append(bluetoothVisible);
		result.append(", bluetoothOn: ");
		result.append(bluetoothOn);
		result.append(", connectionStatus: ");
		result.append(connectionStatus);
		result.append(", iD: ");
		result.append(iD);
		result.append(')');
		return result.toString();
	}

} //RobotImpl
